Cleanup mem leak in geoniche.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 19 Apr 2006 20:26:31 +0000 (20:26 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 19 Apr 2006 20:26:31 +0000 (20:26 +0000)
gpsbabel/geoniche.c

index 8e659d2e2d7e06711eb554dd7280b841fa952708..e5bf8e6aa1ebe60ed5b7834a3f39354407401cb7 100644 (file)
@@ -648,6 +648,7 @@ geoniche_writewpt(const waypoint *wpt)
     char               *notes;
     int                        id;
     time_t             tx;
+    char               *gs;
 
     if (ct == 0)
     {
@@ -684,7 +685,13 @@ geoniche_writewpt(const waypoint *wpt)
     else
        notes = enscape(wpt->notes);
 
-    notes = xstrappend(notes, geoniche_geostuff(wpt));
+    gs = geoniche_geostuff(wpt);
+    if (gs) {
+       char *newnotes = xstrappend(notes, gs);
+       xfree (notes);
+       xfree (gs);
+       notes = newnotes;
+    }
 
     vdata = (ubyte *) xmalloc(vsize);
     if (vdata == NULL)